﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;

namespace ENMAX_ArcGIS
{
    public class TroubleTicket
    {
        public enum TroubleTicketSeverity
        {
            High = 1,
            Medium = 2,
            Low = 3,
        }

        private string number;
        public string Number
        {
            get
            {
                return number;
            }

            set
            {
                number = value;
            }
        }

        private string desc;
        public string Description
        {
            get
            {
                return desc;
            }
            set
            {
                desc = value;
            }
        }

        private TroubleTicketSeverity severity = TroubleTicketSeverity.Medium;
        public TroubleTicketSeverity Severity
        {
            get
            {
                return severity;
            }
            set
            {
                severity = value;
            }
        }

        private MapPoint map_pt;
        public MapPoint MapCoordinate
        {
            get
            {
                return map_pt;
            }
        }

        private Point mf_center;
        public Point MapFrameCenter
        {
            get
            {
                return mf_center;
            }
            set
            {
                mf_center = value;
            }
        }

        private double mf_width;
        public double MapFrameWidth
        {
            get
            {
                return mf_width;
            }
            set
            {
                mf_width = value;
            }
        }

        private double mf_height;
        public double MapFrameHeight
        {
            get
            {
                return mf_height;
            }
            set
            {
                mf_height = value;
            }
        }

        private Envelope mf_env;
        public Envelope MapFrameEnvelope
        {
            get
            {
                return mf_env;
            }
            set
            {
                mf_env = value;
            }
        }

        private bool prev_open;
        public bool MapFramePreviouslyOpen
        {
            get
            {
                return prev_open;
            }
            set
            {
                prev_open = value;
            }
        }

        private bool current_open;
        public bool MapFrameCurrentlyOpen
        {
            get
            {
                return current_open;
            }
            set
            {
                current_open = value;
            }
        }

        private double orient;
        public double MapFrameOrientation
        {
            get
            {
                return orient;
            }
            set
            {
                orient = value;
            }
        }

        public TroubleTicket(MapPoint location, string description, string num, TroubleTicketSeverity sev)
        {
            number = num;
            desc = description;
            severity = sev;

            map_pt = location;
            mf_env = new Envelope(location.X - 0.0001, location.Y - 0.0001, location.X + 0.0001, location.Y + 0.0001);
            mf_center = new Point(-1, -1);
            mf_height = 270;
            mf_width = 270;
            prev_open = false;
            current_open = false;
            mf_env = null;
            orient = 0;
        }

        public TroubleTicket(Envelope envelope, string description, string num, TroubleTicketSeverity sev)
        {
            number = num;
            desc = description;
            severity = sev;

            map_pt = new MapPoint(envelope.XMin + ((envelope.XMax - envelope.XMin) / 2), envelope.YMin + ((envelope.YMax - envelope.YMin) / 2));
            mf_env = envelope;
            mf_center = new Point(-1, -1);
            mf_height = 270;
            mf_width = 270;
            prev_open = false;
            current_open = false;
            orient = 0;
        }

        public string getTroubleTicketSeverityString()
        {
            switch (Severity)
            {
                case TroubleTicket.TroubleTicketSeverity.High: { return "High"; }
                case TroubleTicket.TroubleTicketSeverity.Medium: { return "Meduim"; }
                case TroubleTicket.TroubleTicketSeverity.Low: { return "Low"; }
                default: { return string.Empty; }
            }
        }
    }
}